package org.nobject.common.fan;

import java.io.File;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;

import org.nobject.common.file.FileUtils;

/**
 * FindString
 *
 * @author bianrongjun
 * @version 1.0
 */
public class FindString {
	
	/**
	 * 查找内容
	 * 
	 * EXP:
	 * findString("D:\\WOR_HOME\\ECLIPSE_WORKSPACE\\pss\\trunk\\WebRoot\\user","jsp","jboss-portal");
	 * 
	 * @param path
	 * @param ext
	 * @param ctx
	 */
	public static List findString(String path,String ext,String ctx){
		Set files = FileUtils.getSubFilePathes(path, new String[]{".*\\."+ext}, true);//Files(path, ext, true);
		List fileList=new LinkedList();
		for (Iterator iterator = files.iterator(); iterator.hasNext();) {
			String filePath= (String) iterator.next();
			File file=new File(filePath);
			if(FileUtils.readFile(file).indexOf(ctx)>=0){
				fileList.add(filePath);
			}
		}
		return fileList;
	}
}
